package cn.sptpc.service.impl;

import cn.sptpc.dao.GroupDao;
import cn.sptpc.dao.impl.GroupDaoI;
import cn.sptpc.entity.java.Group;
import cn.sptpc.entity.web.JGroupAllEntity;
import cn.sptpc.service.GroupService;
import com.google.gson.Gson;

import java.util.List;

public class GroupServiceI implements GroupService {
    private GroupDao dao = new GroupDaoI();
    @Override
    public String getAllGroupByDeparment(int id) {
        List<Group> groups = dao.findGroupByDepartment(id);
        JGroupAllEntity entity = new JGroupAllEntity();
        Gson gson = new Gson();
        entity.setData(groups);
        return gson.toJson(entity);
    }
}
